

//-------Aliases-------//
private alias object.value0 : object.red
private alias object.value1 : object.blu
private alias object.value2 : object.grn

private alias object.value10 : object.store
private alias object.value20 : object.process

public alias saveRAM[294] : saved.graphics

// Static Values

// Tables

reserve function processColor
reserve function actualColor

event ObjectMain
	temp0 = 0
	while temp0 < 8
		temp1 = 0
		while temp1 < 256
			GetPaletteEntry(temp0, temp1, object.store)			
			CallFunction(processColor)			
			SetPaletteEntry(temp0, temp1, object.store)
			temp1++
		loop
	temp0++
	loop	
	
	switch object.propertyValue
		case 0
			color1 = 32
			color2 = 64
			color3 = 96
			color4 = 128
			color5 = 160
			color6 = 192
			color7 = 224
			break
		case 1
			color1 = 36
			color2 = 72
			color3 = 108
			color4 = 144
			color5 = 180
			color6 = 216
			color7 = 252
			break
		case 2
			color1 = 52
			color2 = 87
			color3 = 116
			color4 = 144
			color5 = 172
			color6 = 206
			color7 = 255
			break			
	end switch
	
	
	
	object.type = TypeName[Blank Object]
end event

function processColor
	switch object.propertyValue
		case 0 //mobile
			//object.store &= 0xE0E0E0
			break
		case 1 //emulated
	
			break
		case 2 //hardware
			object.process = object.store
			object.process &= 0xE00000
			object.process >>= 21
			CallFunction(actualColor)
			object.red = object.process
			object.red <<= 16				
			
			object.process = object.store
			object.process &= 0x00E000
			object.process >>= 13
			CallFunction(actualColor)
			object.grn = object.process
			object.grn <<= 8
			
			object.process = object.store
			object.process &= 0xE0
			object.process >>= 5
			CallFunction(actualColor)
			object.blu = object.process				
			
			object.store = object.red
			object.store += object.blu
			object.store += object.grn
			break
	end switch
end function

function actualColor
	switch object.process
		case 0
			object.process = 0
			break
		case 1
			object.process = 52
			break
		case 2
			object.process = 87
			break
		case 3
			object.process = 116
			break
		case 4
			object.process = 144
			break
		case 5
			object.process = 172
			break
		case 6
			object.process = 206
			break
		case 7
			object.process = 255
			break
	end switch
end function


event ObjectDraw
end event


event ObjectStartup
	CreateTempObject(TypeName[Palette Police], saved.graphics, 0, 0)
	object[tempObjectPos].priority = PRIORITY_ACTIVE_PAUSED
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
